package cn.icare.cms.controller;

import cn.icare.cms.ItemCatService;
import cn.icare.cms.model.ro.AddItemCatRO;
import cn.icare.cms.model.ro.EditItemCatRO;
import cn.icare.cms.model.vo.rest.RespMsgVO;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping(value = "/rest/itemcat")
@Api(tags = "REST商品分类")
public class ItemCatController extends BaseController {
    @Resource
    private ItemCatService itemCatService;
    private final String FALL_STRING = "请求失败,服务繁忙!";


    /**
     * URL:http://{ip}:{port}/rest/itemcat?args={args}
     * method:GET
     *
     * @return
     */
    @GetMapping()
    @ApiOperation(value = "根据父类Id查询商品分类分类", notes = "根据父类Id查询商品分类分类,一级目录parentId:0")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "parentId", value = "商品父类Id,一级目录parentId:0", required = true, defaultValue = "0", paramType = "query", dataTypeClass = Long.class)
    })
    public ResponseEntity<RespMsgVO> getList(
            Long parentId
    ) {
        return super.getRespOk(this.itemCatService.getList(parentId, "", 0, 0));
    }
    //#region fallback methods

    private ResponseEntity<RespMsgVO> getListFall(Long parentId) {

        return super.getRespFail(this.FALL_STRING);
    }
    //#endregion

}
